home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9684 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.6 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: malloc question
  5. Date: 12 Mar 1996 20:14:07 GMT
  6. Organization: Los Alamos National Laboratory
  7. Distribution: world
  8. Message-ID: <TANMOY.96Mar12131407@qcd.lanl.gov>
  9. References: <4htonk$350@news.hklink.net> <danpop.826488975@rscernix>
  10.     <4i44vk$g16@rigel.rz.uni-ulm.de>
  11. NNTP-Posting-Host: qcd.lanl.gov
  12. Mime-Version: 1.0
  13. Content-Type: text
  14. In-reply-to: peinel@faw.uni-ulm.de's message of 12 Mar 1996 15:24:36 GMT
  15.  
  16. In article <4i44vk$g16@rigel.rz.uni-ulm.de>
  17. peinel@faw.uni-ulm.de (Gertraud Peinel) writes:
  18. <snip>
  19. GP: |> You DON'T have to cast the value returned by malloc, casting it is actually
  20. GP: |> a BAD idea.  But you DO have to include <stdlib.h> in any source file
  21. GP: |> which calls malloc.
  22. GP: 
  23. GP: Hmmm, and what should I do with this (especially when I have to use these
  24. GP: compilers) ? :
  25. GP: 
  26. GP:   sun5:/users/peinel/clang(36)> uname -a
  27. GP:   SunOS sun5 4.1.3 3 sun4c
  28. GP:   sun5:/users/peinel/clang(35)> cat oh.c 
  29. GP:   #include <stdlib.h>
  30. GP: 
  31. GP:   typedef struct item {
  32. GP:     int val;
  33. GP:     struct item *next;
  34. GP:   } ITEM, *PITEM;
  35. GP: 
  36. GP:   main()
  37. GP:   {
  38. GP:     PITEM head, current;
  39. GP:     head= malloc(sizeof(ITEM));
  40. GP:     head->val=1;
  41. GP:   }
  42. GP:   sun5:/users/peinel/clang(29)> cc oh.c
  43. GP:   "oh.c", line 11: warning: illegal pointer combination
  44. GP:   sun5:/users/peinel/clang(34)> which cc
  45. GP:   /bin/cc
  46. GP:   sun5:/users/peinel/clang(32)> CC oh.c
  47. GP:   CC  mist.c:
  48. GP:   "oh.c", line 11: error: no standard conversion of  char * to  struct item *
  49. GP:   "oh.c", line 10: warning:  current not used
  50. GP:   1 error
  51. GP:   sun5:/users/peinel/clang(33)> which CC
  52. GP:   /com/owc++/bin/CC
  53. GP: 
  54. GP: Without casting ?
  55.  
  56. Complain to the vendor that they have a misleading name for their
  57. program. Neither cc nor CC is a C compiler under either the current
  58. international standard meaning of that term.
  59.  
  60. In the meantime, you can get an install the excellent free C compiler
  61. available for your platform. Commercial compilers for the language
  62. under discussion is also available for this particular platform.
  63.  
  64. A suitable name for cc would probably be kr1c :-) I do not know what
  65. CC is.
  66.  
  67. Cheers
  68. Tanmoy
  69.  
  70. --
  71. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  72. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  73. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  74. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  75. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  76. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  77.